﻿using AnesSystem.Models;
using AnesSystem.Services;
using AnesSystem.Util;
using AnesSystem.ViewModels.WorkScore;
using Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace AnesSystem.Controls
{
    /// <summary>
    /// WorkScoreStatistics.xaml 的交互逻辑
    /// </summary>
    public partial class WorkScoreStatisticsTableCtrl : UserControl
    {


        public WorkScoreStatisticsTableCtrl()
        {
            InitializeComponent();
            _startDate.SelectedDateTime = DateTime.Now;
            _endDate.SelectedDateTime = DateTime.Now;
            this.DataContext = WorkScoreStatisticsCtrlViewMode.Instance;
            this.Loaded += WorkScoreStatisticsTableCtrl_Loaded;
        }

        //刷新
        private void WorkScoreStatisticsTableCtrl_Loaded(object sender, RoutedEventArgs e)
        {
            
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //if (this._startDate.SelectedDateTime < this._endDate.SelectedDateTime)
            WorkScoreStatisticsCtrlViewMode.Instance.Seach();

        }

        public void SelectButtonClick(object sender, RoutedEventArgs e)
        {
            DateTime startDateTime = Convert.ToDateTime(_startDate.SelectedDateTime.ToShortDateString().ToString());
            DateTime endDateTime = Convert.ToDateTime(_endDate.SelectedDateTime.ToShortDateString().ToString());
            WorkScoreStatisticsCtrlViewMode.Instance.SelectDat(startDateTime, endDateTime);
        }

        private void AddButtonClick(object sender, RoutedEventArgs e)
        {
            WorkScoreStatisticsCtrlViewMode.Instance.AddWorkScore();
        }
        private void _dgNoSchedule_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                BaseCountModel baseCountModel = _dgNoSchedule.SelectedItem as BaseCountModel;
                WorkScoreStatisticsCtrlViewMode.Instance.UpdateDisWorkScoreModelList(baseCountModel);
            }
            catch (Exception ex)
            {
                Common.LogHelper.Error("NoSecheduledListCtrl", ex);
            }
        }

        private void Dcexcel_Click(object sender, RoutedEventArgs e)
        {
            WorkScoreStatisticsCtrlViewMode.Instance.WorkScoreDcexcel();
        }
        
    }
}
